package edu.calvin.djs32.cs214.interpreters.support;

import java.util.ArrayList;
import java.util.List;

import org.easymock.EasyMock;

public class EasyMockControl {

	  private final List<Object>  myMocks;

	  public EasyMockControl() {
	    myMocks = new ArrayList<Object>();
	  }

	  public <T> T[] createMocks(T[] array, Class<T> name) {
	    for (int i = 0; i < array.length; i++) {
	      array[i] = createMock(name);
	    }
	    return array;
	  }

	  public void replay() {
	    EasyMock.replay(myMocks.toArray());
	  }

	  public void verify() {
	    EasyMock.verify(myMocks.toArray());
	  }

	  public void reset() {
	    EasyMock.reset(myMocks.toArray());
	  }

	  public <T> T createMock(Class<T> name) {
	    T mock = org.easymock.EasyMock.createMock(name);
	    myMocks.add(mock);
	    return mock;
	  }

	}